<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <link rel="stylesheet" href="styles/style.css">
        <link rel="stylesheet" href="styles/theme/atom-one-dark.css">
        <title>例子14-ES6/7常用语法介绍</title>
    </head>
    <body>
        <pre>
            <code>
                // 例子14

                const x = 1, y = 1;
                function minus(x, y) {
                        return x - y;
                }
                console.log(`x = ${x}, y = ${y}, x + y = ${x + y}, x - y = ${minus(x, y)}`);
                // "x = 1, y = 1, x + y = 2, x - y = 0"

                //--------------------------------------------------------------------------

                const items = [
                    {
                            id: 1,
                            name: 'Tom'
                    },
                    {
                            id: 2,
                            name: 'Jerry'
                    }
                ]
                let html = `
                    <div class="user-list">
                        <ul>
                            ${items.map((value, key) => {`
                                ${console.log(key, value)}
                                <li data-id="${value.id}">${value.name}</li>
                            `}).join('')}
                        </ul>
                    </div>
                `;
                $('#result').append(html);
            </code>
        </pre>
        <script src="scripts/libs/highlight.pack.js"></script>
        <script src="scripts/14.js"></script>
        <script>
            hljs.initHighlightingOnLoad();
        </script>
    </body>
</html>